package com.wm.web.controller.system;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;

import com.wm.common.core.domain.AjaxResult;
import com.wm.common.utils.SecurityUtils;
import com.wm.common.utils.bean.BeanUtils;
import com.wm.system.domain.vo.SysMissionVo;
import com.wm.system.filter.SysMissionSearchContext;
import com.wm.system.service.ISysMissionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

@Api(tags = "待办信息")
@RestController
@RequestMapping("/system/mission")
public class SysMissionController {

    @Autowired
    private ISysMissionService missionService;

    @ApiOperation("分页查询我的待办信息")
    @PreAuthorize("@ss.hasPermi('system:mission:list')")
    @GetMapping("/myMission")
    public AjaxResult myMission(SysMissionSearchContext context) {
        Long userId = SecurityUtils.getLoginUser().getUser().getUserId();
        context.setUid(userId);

        Page page = missionService.getPage(context);
        page.setRecords(BeanUtils.copyListProperties(page.getRecords(), SysMissionVo::new));
        return AjaxResult.success(page);
    }

}
